home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / H / tmp / miscadmin.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  13.8 KB  |  752 lines

  1. /* ----------------------------------------------------------------
  2.  *   FILE
  3.  *    miscadmin.h
  4.  *
  5.  *   DESCRIPTION
  6.  *    this file contains general postgres administration and
  7.  *    initialization stuff that used to be spread out
  8.  *    between the following files:
  9.  *
  10.  *    globals.h            global variables
  11.  *    magic.h                PG_RELEASE, PG_VERSION, etc defines
  12.  *    pdir.h                directory path crud
  13.  *    pinit.h                postgres initialization
  14.  *    pmod.h                processing modes
  15.  *    pusr.h                postgres user permissions
  16.  *    unix.h                host system port, etc.
  17.  *    os.h                system port, etc.
  18.  *
  19.  *   NOTES
  20.  *    some of the information in this file will be moved to
  21.  *    other files.
  22.  *
  23.  *   IDENTIFICATION
  24.  *    $Header: /private/postgres/src/lib/H/tmp/RCS/miscadmin.h,v 1.12 1992/06/10 05:08:59 mer Exp $
  25.  * ----------------------------------------------------------------
  26.  */
  27. #ifndef MiscadminHIncluded
  28. #define MiscadminHIncluded 1
  29.  
  30. /* ----------------
  31.  *    note: <sys/types.h> was in unix.h  This should be moved
  32.  *    to the .c files.
  33.  * ----------------
  34.  */
  35. #include <sys/types.h>
  36.  
  37. #include "tmp/postgres.h"
  38. #include "storage/backendid.h"
  39.  
  40. /* ----------------
  41.  *    globals.h
  42.  * ----------------
  43.  */
  44. /*
  45.  * globals.h --
  46.  *
  47.  */
  48.  
  49. #ifndef    GlobalsIncluded        /* Include this file only once */
  50. #define    GlobalsIncluded    1
  51.  
  52. /*
  53.  * Identification:
  54.  */
  55. #define GLOBALS_H    "$Header: /private/postgres/src/lib/H/tmp/RCS/miscadmin.h,v 1.12 1992/06/10 05:08:59 mer Exp $"
  56.  
  57. extern int Debugfile;
  58. extern int Ttyfile;
  59. extern int Portfd;
  60. extern int Packfd;
  61. extern int Pipefd;
  62. extern int Noversion;        /* moved from magic.c    */
  63.  
  64. /*
  65.  * done in storage/backendid.h for now.
  66.  *
  67.  * extern BackendId    MyBackendId;
  68.  * extern BackendTag   MyBackendTag;
  69.  */
  70. extern NameData        MyDatabaseNameData;
  71. extern Name        MyDatabaseName;
  72. extern bool        MyDatabaseIdIsInitialized;
  73. extern ObjectId        MyDatabaseId;
  74. extern bool        TransactionInitWasProcessed;
  75.  
  76. extern bool        IsUnderPostmaster;
  77.  
  78. extern struct bcommon Ident;    /* moved from dlog */
  79.  
  80. extern ObjectId        LastOidProcessed;    /* for query rewrite */
  81.  
  82. #define MAX_PARSE_BUFFER 8192
  83.  
  84. /* 
  85.  *    default number of buffers in buffer pool
  86.  * 
  87.  */
  88. #define NDBUFS 64
  89.  
  90. #endif    /* !defined(GlobalsIncluded) */
  91.  
  92. /* ----------------
  93.  *    magic.h
  94.  * ----------------
  95.  */
  96. #ifndef    _MAGIC_H_
  97. #define    _MAGIC_H_    "$Header: /private/postgres/src/lib/H/tmp/RCS/miscadmin.h,v 1.12 1992/06/10 05:08:59 mer Exp $"
  98.  
  99. /*
  100.  *    magic.h        - definitions of the indexes of the magic numbers
  101.  */
  102.  
  103. #define    PG_RELEASE    1
  104. #define PG_VERSION    1
  105. #define    PG_VERFILE    "PG_VERSION"
  106.  
  107. #define    M_RELATION_R    0
  108. #define    M_ADT_R        1
  109. #define    M_INT4_EQ_F    2
  110.  
  111. /* #define    NMAGIC        3*/
  112.  
  113. #endif
  114.  
  115. /* ----------------
  116.  *    pdir.h
  117.  * ----------------
  118.  */
  119. /*
  120.  * pdir.h --
  121.  *    POSTGRES directory path definitions.
  122.  *
  123.  * Identification:
  124.  *    $Header: /private/postgres/src/lib/H/tmp/RCS/miscadmin.h,v 1.12 1992/06/10 05:08:59 mer Exp $
  125.  */
  126.  
  127. #ifndef    PDirIncluded        /* Include this file only once */
  128. #define PDirIncluded    1
  129.  
  130. #define PDIR_H    "$Header: /private/postgres/src/lib/H/tmp/RCS/miscadmin.h,v 1.12 1992/06/10 05:08:59 mer Exp $"
  131.  
  132. /*
  133.  * GetDatabasePath --
  134.  *    Returns path to database.
  135.  *
  136.  * Exceptions:
  137.  *    BadState if called before InitDatabase.
  138.  */
  139. extern
  140. String        /* XXX Path */
  141. GetDatabasePath ARGS((
  142.     void
  143. ));
  144.  
  145. extern
  146. void
  147. SetDatabasePath ARGS((
  148.     String path
  149. ));
  150.  
  151. void
  152. SetDatabaseName ARGS((String name));
  153.  
  154. /*
  155.  * GetDatabaseName --
  156.  *    Returns name of database.
  157.  *
  158.  * Exceptions:
  159.  *    BadState if called before InitDatabase.
  160.  */
  161. extern
  162. String        /* XXX Name */
  163. GetDatabaseName ARGS((
  164.     void
  165. ));
  166.  
  167. /*
  168.  * DoChdirAndInitDatabaseNameAndPath --
  169.  *    Sets current directory appropriately for given path and name.
  170.  *
  171.  * Arguments:
  172.  *    Path and name are invalid if it invalid as a string.
  173.  *    Path is "badly formated" if it is not a string containing a path
  174.  *    to a writable directory.
  175.  *    Name is "badly formated" if it contains more than 16 characters or if
  176.  *    it is a bad file name (e.g., it contains a '/' or an 8-bit character).
  177.  *
  178.  * Side effects:
  179.  *    Initially, DatabasePath and DatabaseName are invalid.  They are
  180.  *    set to valid strings before this function returns.
  181.  *
  182.  * Exceptions:
  183.  *    BadState if called more than once.
  184.  *    BadArg if both path and name are "badly formated" or invalid.
  185.  *    BadArg if path and name are both "inconsistent" and valid.
  186.  */
  187. extern
  188. void
  189. DoChdirAndInitDatabaseNameAndPath ARGS((
  190.     String    name,
  191.     String    path
  192. ));
  193.  
  194. #endif    /* !defined(PDirIncluded) */
  195.  
  196. /* ----------------
  197.  *    pinit.h
  198.  * ----------------
  199.  */
  200. /*
  201.  * pinit.h --
  202.  *    POSTGRES initialization and cleanup definitions.
  203.  *
  204.  * Note:
  205.  *    XXX AddExitHandler not defined yet.
  206.  *
  207.  * Identification:
  208.  *    $Header: /private/postgres/src/lib/H/tmp/RCS/miscadmin.h,v 1.12 1992/06/10 05:08:59 mer Exp $
  209.  */
  210.  
  211. #ifndef    PInitIncluded
  212. #define PInitIncluded    1    /* Include this file only once */
  213.  
  214. typedef    int16    ExitStatus;
  215.  
  216. #define    NormalExitStatus    (0)
  217. #define    FatalExitStatus        (127)
  218. /* XXX are there any other meaningful exit codes? */
  219.  
  220. void
  221. InitMyDatabaseId ARGS(());
  222. void
  223. InitCommunication ARGS(());
  224. void
  225. InitStdio ARGS(());
  226.  
  227. /*
  228.  * InitPostgres --
  229.  *    Initialize POSTGRES.
  230.  *
  231.  * Note:
  232.  *    ...
  233.  *
  234.  * Side effects:
  235.  *    ...
  236.  *
  237.  * Exceptions:
  238.  *    none
  239.  */
  240. extern
  241. void
  242. InitPostgres ARGS((
  243.     String    name
  244. ));
  245.  
  246. /*
  247.  * ReinitPostgres --
  248.  *    Resets POSTGRES to a "sane" state.
  249.  *
  250.  * Note:
  251.  *    Some things like communication to a frontend or database cannot
  252.  *    be reset.
  253.  *    ...
  254.  *
  255.  * Side effects:
  256.  *    ...
  257.  *
  258.  * Exceptions:
  259.  *    none
  260.  */
  261. extern
  262. void
  263. ReinitPostgres ARGS((
  264.     void
  265. ));
  266.  
  267. /*
  268.  * ExitPostgres --
  269.  *    Exit POSTGRES with a status code.
  270.  *
  271.  * Note:
  272.  *    This function never returns.
  273.  *    ...
  274.  *
  275.  * Side effects:
  276.  *    ...
  277.  *
  278.  * Exceptions:
  279.  *    none
  280.  */
  281. extern
  282. void
  283. ExitPostgres ARGS((
  284.     ExitStatus    status
  285. ));
  286.  
  287. void StatusBackendExit ARGS((int status));
  288. void StatusPostmasterExit ARGS((int status));
  289.  
  290. /*
  291.  * AbortPostgres --
  292.  *    Abort POSTGRES dumping core.
  293.  *
  294.  * Note:
  295.  *    This function never returns.
  296.  *    ...
  297.  *
  298.  * Side effects:
  299.  *    Core is dumped iff EnableAbortEnvVarName is set to a non-empty string.
  300.  *    ...
  301.  *
  302.  * Exceptions:
  303.  *    none
  304.  */
  305. extern
  306. void
  307. AbortPostgres ARGS((
  308.     void
  309. ));
  310.  
  311. #endif    /* !defined(PInitIncluded) */
  312.  
  313. /* ----------------
  314.  *    pmod.h
  315.  * ----------------
  316.  */
  317. /*
  318.  * pmod.h --
  319.  *    POSTGRES processing mode definitions.
  320.  *
  321.  * Description:
  322.  *    There are four processing modes in POSTGRES.  They are NoProcessing
  323.  * or "none," BootstrapProcessing or "bootstrap," InitProcessing or
  324.  * "initialization," and NormalProcessing or "normal."
  325.  *
  326.  *    If a POSTGRES binary is in normal mode, then all code may be executed
  327.  * normally.  In the none mode, only bookkeeping code may be called.  In
  328.  * particular, access method calls may not occur in this mode since the
  329.  * execution state is outside a transaction.
  330.  *
  331.  *    The final two processing modes are used during special times.  When the
  332.  * system state indicates bootstrap processing, transactions are all given
  333.  * transaction id "one" and are consequently guarenteed to commit.  This mode
  334.  * is used during the initial generation of template databases.
  335.  *
  336.  * Finally, the execution state is in initialization mode until all normal
  337.  * initialization is complete.  Some code behaves differently when executed in
  338.  * this mode to enable system bootstrapping.
  339.  */
  340.  
  341. #ifndef    PModIncluded        /* Include this file only once */
  342. #define PModIncluded    1
  343.  
  344. /*
  345.  * Identification:
  346.  */
  347. #define PMOD_H    "$Header: /private/postgres/src/lib/H/tmp/RCS/miscadmin.h,v 1.12 1992/06/10 05:08:59 mer Exp $"
  348.  
  349. typedef enum ProcessingMode {
  350.     NoProcessing,        /* "nothing" can be done */
  351.     BootstrapProcessing,    /* bootstrap creation of template database */
  352.     InitProcessing,        /* initializing system */
  353.     NormalProcessing,    /* normal processing */
  354. } ProcessingMode;
  355.  
  356. /*
  357.  * IsNoProcessingMode --
  358.  *    True iff processing mode is NoProcessing.
  359.  */
  360. extern
  361. bool
  362. IsNoProcessingMode ARGS((
  363.     void
  364. ));
  365.  
  366. /*
  367.  * IsBootstrapProcessingMode --
  368.  *    True iff processing mode is BootstrapProcessing.
  369.  */
  370. extern
  371. bool
  372. IsBootstrapProcessingMode ARGS((
  373.     void
  374. ));
  375.  
  376. /*
  377.  * IsInitProcessingMode --
  378.  *    True iff processing mode is InitProcessing.
  379.  */
  380. extern
  381. bool
  382. IsInitProcessingMode ARGS((
  383.     void
  384. ));
  385.  
  386. /*
  387.  * IsNormalProcessingMode --
  388.  *    True iff processing mode is NormalProcessing.
  389.  */
  390. extern
  391. bool
  392. IsNormalProcessingMode ARGS((
  393.     void
  394. ));
  395.  
  396. /*
  397.  * SetProcessingMode --
  398.  *    Sets mode of processing as specified.
  399.  *
  400.  * Exceptions:
  401.  *    BadArg if called with invalid mode.
  402.  *
  403.  * Note:
  404.  *    Mode is NoProcessing before the first time this is called.
  405.  */
  406. extern
  407. void
  408. SetProcessingMode ARGS((
  409.     ProcessingMode    mode
  410. ));
  411.  
  412. #endif    /* !defined(PModIncluded) */
  413.  
  414. extern char *GetPGHome ARGS((void));
  415.  
  416. /* ----------------
  417.  *    pusr.h
  418.  * ----------------
  419.  */
  420. /*
  421.  * pusr.h --
  422.  *    POSTGRES user permissions definitions.
  423.  *
  424.  * Identification:
  425.  *    $Header: /private/postgres/src/lib/H/tmp/RCS/miscadmin.h,v 1.12 1992/06/10 05:08:59 mer Exp $
  426.  */
  427.  
  428. #ifndef    PUsrIncluded        /* Include this file only once */
  429. #define PUsrIncluded    1
  430.  
  431. #define PUSR_H    "$Header: /private/postgres/src/lib/H/tmp/RCS/miscadmin.h,v 1.12 1992/06/10 05:08:59 mer Exp $"
  432.  
  433. /*
  434.  * GetUserId --
  435.  *    Returns user id.
  436.  *
  437.  * Exceptions:
  438.  *    BadState if called before InitUser.
  439.  */
  440. extern
  441. ObjectId
  442. GetUserId ARGS((void));
  443.  
  444. extern
  445. void
  446. SetUserId ARGS((void));
  447.  
  448. /*
  449.  * InitUser --
  450.  *    Sets user permission information.
  451.  *
  452.  * Exceptions:
  453.  *    BadState if called more than once.
  454.  */
  455. extern
  456. void
  457. InitUser ARGS((
  458.     void
  459. ));
  460.  
  461. #endif    /* !defined(PUsrIncluded) */
  462.  
  463. /* ----------------
  464.  *    unix.h
  465.  * ----------------
  466.  */
  467. /*
  468.  * unix.h --
  469.  *    UNIX operating system definitions.
  470.  *
  471.  * Note:
  472.  *    This file is for the Sun UNIX OPERATING SYSTEM 3.4 or 3.5 or 3.6!!!
  473.  *
  474.  * Identification:
  475.  *    $Header: /private/postgres/src/lib/H/tmp/RCS/miscadmin.h,v 1.12 1992/06/10 05:08:59 mer Exp $
  476.  */
  477.  
  478. #ifndef    UNIXIncluded        /* Include this file only once */
  479. #define UNIXIncluded    1
  480.  
  481.  
  482. /*
  483.  * HostSystemPort --
  484.  *    Unbuffered system I/O port.
  485.  */
  486. typedef int    HostSystemPort;
  487.  
  488. /*
  489.  * HostSystemFileMode --
  490.  *    File mode.
  491.  */
  492. typedef int    HostSystemFileMode;
  493.  
  494. /*
  495.  * HostSystemByteCount --
  496.  *    Number of bytes--used in calls to read, write, etc.
  497.  */
  498. typedef int    HostSystemByteCount;
  499.  
  500. /*
  501.  * HostSystemFilePosition --
  502.  *    Number of bytes from beginning of file.
  503.  */
  504. typedef long    HostSystemFilePosition;
  505.  
  506. /*
  507.  * HostSystemFileOffset --
  508.  *    Number of offset bytes for lseek.
  509.  */
  510. typedef long    HostSystemFileOffset;
  511.  
  512. /*
  513.  * HostSystemTime --
  514.  *    Time in seconds from the UNIX epoch.
  515.  */
  516. typedef time_t    HostSystemTime;
  517.  
  518. /*
  519.  * open --
  520.  *    open(2)
  521.  */
  522. #if old_sun_no_longer_supported
  523. extern
  524. HostSystemPort
  525. open ARGS((
  526.     const String            path,
  527.     const int            flags,
  528.     const HostSystemFileMode    mode
  529. ));
  530.  
  531. /*
  532.  * close --
  533.  *    close(2)
  534.  */
  535. extern
  536. void
  537. close ARGS((
  538.     const HostSystemPort    port
  539. ));
  540.  
  541. /*
  542.  * read --
  543.  *    read(2)
  544.  *
  545.  * Note:
  546.  *    String may not be proper usage here.
  547.  */
  548. extern
  549. HostSystemByteCount
  550. read ARGS((
  551.     const HostSystemPort        port,
  552.     const String            buffer,
  553.     const HostSystemByteCount    numberBytes
  554. ));
  555.  
  556. /*
  557.  * write --
  558.  *    write(2)
  559.  *
  560.  * Note:
  561.  *    String may not be proper usage here.
  562.  */
  563. extern
  564. HostSystemByteCount
  565. write ARGS((
  566.     const HostSystemPort        port,
  567.     const String            buffer,
  568.     const HostSystemByteCount    numberBytes
  569. ));
  570.  
  571. /*
  572.  * lseek --
  573.  *    lseek(2)
  574.  */
  575. extern
  576. HostSystemFilePosition
  577. lseek ARGS((
  578.     const HostSystemPort        port,
  579.     const HostSystemFileOffset    offset,
  580.     const int            whence
  581. ));
  582.  
  583. /*
  584.  * time --
  585.  *    time(3)
  586.  */
  587. extern
  588. HostSystemTime
  589. time ARGS((
  590.     HostSystemTime    *tloc
  591. ));
  592. #endif
  593.  
  594. /*
  595.  * These tests can be made more strict given a particular compiler.
  596.  *
  597.  * XXX Someday, this should go into the compiler port directory.
  598.  */
  599. #ifndef    __SABER__
  600. #define PointerIsToDynamicData(pointer)    ((bool)((char *)(pointer) >= end))
  601. #define PointerIsToStaticData(pointer)    ((bool)((char *)(pointer) < end))
  602. #else
  603. #define PointerIsToDynamicData(pointer)    (true)
  604. #define PointerIsToStaticData(pointer)    (true)
  605. #endif
  606.  
  607. #endif    /* !defined(UNIXIncluded) */
  608.  
  609. /* ----------------
  610.  *    os.h
  611.  * ----------------
  612.  */
  613. /*
  614.  * os.h --
  615.  *    Operating system definitions.
  616.  *
  617.  * Note:
  618.  *    This file is OPERATING SYSTEM dependent!!!
  619.  *
  620.  * Identification:
  621.  *    $Header: /private/postgres/src/lib/H/tmp/RCS/miscadmin.h,v 1.12 1992/06/10 05:08:59 mer Exp $
  622.  */
  623.  
  624. #ifndef    OSIncluded        /* Include this file only once */
  625. #define OSIncluded    1
  626.  
  627. /*
  628.  * SystemPort --
  629.  *    Unbuffered system I/O port.
  630.  */
  631. typedef HostSystemPort    SystemPort;
  632.  
  633. /*
  634.  * SystemFileMode --
  635.  *    File mode.
  636.  */
  637. typedef HostSystemFileMode    SystemFileMode;
  638.  
  639. /*
  640.  * SystemByteCount --
  641.  *    Number of bytes--used in calls to read, write, etc.
  642.  */
  643. typedef HostSystemByteCount    SystemByteCount;
  644.  
  645. /*
  646.  * SystemFilePosition --
  647.  *    Number of bytes from beginning of file.
  648.  */
  649. typedef HostSystemFilePosition    SystemFilePosition;
  650.  
  651. /*
  652.  * SystemFileOffset --
  653.  *    Number of offset bytes for lseek.
  654.  */
  655. typedef HostSystemFileOffset    SystemFileOffset;
  656.  
  657. /*
  658.  * SystemTime --
  659.  *    Time in seconds.
  660.  */
  661. typedef HostSystemTime    SystemTime;
  662.  
  663. /*
  664.  * open --
  665.  *    open(2)
  666.  */
  667. extern
  668. SystemPort
  669. OpenSystemPortFile ARGS((
  670.     const String        path,
  671.     const int        flags,
  672.     const SystemFileMode    mode
  673. ));
  674.  
  675. /*
  676.  * close --
  677.  *    close(2)
  678.  */
  679. extern
  680. void
  681. CloseSystemPort ARGS((
  682.     const SystemPort    port
  683. ));
  684.  
  685. /*
  686.  * read --
  687.  *    read(2)
  688.  *
  689.  * Note:
  690.  *    String may not be proper usage here.
  691.  */
  692. extern
  693. SystemByteCount
  694. SystemPortRead ARGS((
  695.     const SystemPort    port,
  696.     const String        buffer,
  697.     const SystemByteCount    numberBytes
  698. ));
  699.  
  700. /*
  701.  * write --
  702.  *    write(2)
  703.  *
  704.  * Note:
  705.  *    String may not be proper usage here.
  706.  */
  707. extern
  708. SystemByteCount
  709. SystemPortWrite ARGS((
  710.     const SystemPort    port,
  711.     const String        buffer,
  712.     const SystemByteCount    numberBytes
  713. ));
  714.  
  715. /*
  716.  * lseek --
  717.  *    lseek(2)
  718.  */
  719. extern
  720. SystemFilePosition
  721. SystemPortSeek ARGS((
  722.     const SystemPort    port,
  723.     const SystemFileOffset    offset,
  724.     const int        whence
  725. ));
  726.  
  727. /*
  728.  * PointerIsToStaticData --
  729.  * PointerIsToDynamicData --
  730.  *    True iff pointer points to memory allocated at compile-time or
  731.  *    run-time, respectively.
  732.  *
  733.  * Note:
  734.  *    This is compiler and operating system dependent.
  735.  *    Look in "unix.h", etc. for the appropriate definition.
  736.  */
  737.  
  738. #endif    /* !defined(OSIncluded) */
  739.  
  740. /*
  741.  * Prototypes for utils/init/magic.c
  742.  */
  743. int DatabaseMetaGunkIsConsistent ARGS((char database[], char path[]));
  744. int ValidPgVersion ARGS((char path []));
  745. int SetPgVersion ARGS((char path []));
  746.  
  747. /* ----------------
  748.  *    end of miscadmin.h
  749.  * ----------------
  750.  */
  751. #endif MiscadminHIncluded
  752.